﻿//分析项目
$(".ana_tab").find("a").click(function () {
    $(this).siblings("a").removeClass("on");
    $(this).addClass("on");
    f_GetChartCustomCome();
});

//首次载入事件
$(function () {
    $(".analysis_table tr:even").css("background-color", "#f2f2f2");//统计table样式
    f_GetChartCustomCome();
});


//自由时间选择器
var dateRange = new pickerDateRange('date', {
    startDate: '2014-11-16', // startDate 开始时间
    endDate: '2014-12-22', // endDate 结束时间
    theme: 'ta',
    target: 'asdfasdf', // target 日期选择框摆放的位置, 一般是在 form 中
    success: function (obj) {
        $(".ana_time").find("a").each(function () {
            $(this).removeClass("on");
        });
        f_GetChartCustomCome();
    }
});

//表格
function f_ChartTable(data) {
    $(".ChartItem").remove();
    $.each(data, function (i, item) {

        var strText = "<tr class='ChartItem'><td>" + item.Kid + "</td><td>" + item.Description + "</td><td>" + item.Count + "</td><td>" + item.Statistics + "</td></tr>";
        $("#ChartTable").append(strText);
    });
}
//图形报表
function f_Chart(ChartTitle, ChartLegend, ChartXAxis, ChartSeries, SytleType) {

    var myChart11 = echarts.init(document.getElementById('chartMain'), theme2);

    switch (SytleType) {

        case "c"://柱状图
            option = {
                title: {
                    text: ChartTitle
                },
                tooltip: {
                    trigger: 'axis'
                },
                //legend: {
                //    data: ['预定量', '成交量'],
                //    x: 5,
                //    y: 50
                //},
                toolbox: {
                    show: true,
                    feature: {
                        //mark: { show: true },
                        //dataView: { show: true, readOnly: false },
                        //magicType: { show: true, type: ['line', 'bar'] },
                        restore: { show: true },
                        saveAsImage: { show: true }
                    },
                    x: 'right',
                    y: 50
                },
                calculable: true,
                xAxis: [
                    {
                        type: 'category',
                        //boundaryGap: false,
                        data: ChartXAxis
                    }
                ],
                yAxis: [
                    {
                        type: 'value'
                    }
                ],
                series: ChartSeries
            };
            break;
        case "l"://线形图
            option = {
                title: {
                    text: ChartTitle
                },
                tooltip: {
                    trigger: 'axis'
                },
                //legend: {
                //    data: ChartLegend,
                //    x: 5,
                //    y: 50
                //},
                toolbox: {
                    show: true,
                    feature: {
                        //mark: { show: true },//辅助性
                        //dataView: { show: true, readOnly: false },//显示table数据
                        //magicType: { show: true, type: ['line', 'bar', 'pie'] },
                        restore: { show: true },//刷新
                        saveAsImage: { show: true }//保存图片
                    },
                    x: 'right',
                    y: 50
                },
                calculable: true,
                xAxis: [
                    {
                        type: 'category',
                        boundaryGap: false,
                        data: ChartXAxis
                    }
                ],
                yAxis: [
                    {
                        type: 'value'
                    }
                ],
                series: ChartSeries
            };

            break;
        case "p"://饼图

            option = {
                title: {
                    text: ChartTitle
                },
                tooltip: {
                    trigger: 'item',
                    formatter: "{a} <br/>{b} : {c} ({d}%)"
                },
                //legend: {
                //    orient: 'vertical',
                //    x: 'left',
                //    data: ['直接访问', '邮件营销', '联盟广告', '视频广告', '搜索引擎']
                //},
                toolbox: {
                    show: true,
                    feature: {
                        //mark: { show: true },
                        //dataView: { show: true, readOnly: false },
                        //magicType: {
                        //    show: true,
                        //    type: ['pie', 'funnel'],
                        //    option: {
                        //        funnel: {
                        //            x: '25%',
                        //            width: '50%',
                        //            funnelAlign: 'left',
                        //            max: 1548
                        //        }
                        //    }
                        //},
                        restore: { show: true },
                        saveAsImage: { show: true }
                    },
                    x: 'right',
                    y: 50
                },
                calculable: true,
                series: ChartSeries
            };
            break;
    }


    myChart11.setOption(option);
}